function [ P_Harmonics, t, ydata, z1, y, Yfft, delta_t, L, Tp ] = PressureOnlyFunc( SaveLocation, ...
    InputFilesLocation, instructionText, FileTypeInput, uploadFlag )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

%% Error Checking and import validation
%%Documentation everything

%% Overall Program 

%% Step 0 Add to path needed functions

cd(InputFilesLocation)

%% Import Error Checking

set(instructionText, 'string', 'Please select the file containing the pressure data you wish to use as input')
[filePathPressure, fileName] = checkPressureFileType(FileTypeInput);


%% Import Files/Data

% Pressure - will import into object strucutre (.txt) -> Output: Pressure

if FileTypeInput == 0
    PatientID = importfile_PatientID(filePathPressure);
    age = importfile_age(filePathPressure);
    heartrate=importfile_HR(filePathPressure);
    inputdata = importfile_pressure(filePathPressure); % returns just p values
    samplingfreq=importfile_sampelingfreq(filePathPressure);

elseif FileTypeInput == 1
    
    [NUM,TXT,RAW]=xlsread(filePathPressure);
    PatientID = char(TXT(1));
    try %Accounts for inconsistant formatting of the xls files
        heartrate = cell2mat(TXT(4)); heartrate = heartrate(4:5); heartrate = str2num(heartrate);
    catch ME 
        heartrate = cell2mat(TXT(6)); heartrate = heartrate(4:5); heartrate = str2num(heartrate);
    end
    inputdata = NUM;
    samplingfreq = 128;

elseif FileTypeInput == 2
    
    [PatientID, visitDate, visitTime] = parseFileName(fileName);
    [heartrate, measurement_id] = getheartRateMySql(visitDate, visitTime);
    inputdata = csvread(filePathPressure);
    samplingfreq = 128;
    
else
    
    error('File type input is not either 0, 1, or 2. Please correct.')
    
end


Pressure.PatientID = PatientID;
Pressure.HR = heartrate;
Pressure.InputData = inputdata;
Pressure.SamplingFreq = samplingfreq;

clear age PatientID heartrate inputdata samplingfreq

[SaveLocation] = createFigureDirectory(SaveLocation, 'PressureResults');
 
%% Step 1 Import and Process Pressure Data

[TimeOriginal, TimeFinal, FinalPressureValues, SignalPeriod] = sphygmaCorDataProcessing(Pressure.InputData, Pressure.SamplingFreq, ...  
                                                    Pressure.HR);
                                                
Pressure.OutputData = [TimeFinal, FinalPressureValues];
Pressure.Period = SignalPeriod;
Pressure.InputData = [TimeOriginal, Pressure.InputData];

clear TimeOriginal TimeFinal FinalPressureValues SignalPeriod

%% Step 4 Caclulate FFT of both Pressure and Flow waveforms

% Pressure FFT

[Pressure.FFT_Outputs, Pressure.FigFFT, t, ydata, z1, y, Yfft, delta_t, L, Tp] = fftGeneralWithMoreOutputs(Pressure.OutputData(:,2), Pressure.OutputData(:,1), 'Pressure');
saveas(Pressure.FigFFT, strcat(SaveLocation, '/', 'FFT_PressureSanityCheckPlot.jpg'));

%% Step 5 Cacluate Impedence at Each Harmonic
P_Harmonics = Pressure.FFT_Outputs;

%% Step 6 Upload to DB

if FileTypeInput == 2 && uploadFlag == 1 %Upload pressure waveforms and fft and impedance fft
    
    %Upload pressure waveform
    waveformUpload( measurement_id, 'pressure_waveforms', 'pressure', ...
        Pressure.InputData(:,1), Pressure.InputData(:,2) )
    
    %Upload pressure fft
    fftUpload( measurement_id, 'pressure_fft', P_Harmonics(:,2), ...
        P_Harmonics(:,3) )
end
end

